package coffeebar;

import javax.swing.Icon;

public class User implements GridObject {
	int id;
	String name;
	int freecount;
	Icon image;
	float discCoeff;

	public User(int id, String name, int freecount, Icon image, float dCoeff) {
		this.id = id;
		this.name = name;
		this.freecount = freecount;
		this.image = image;
		this.discCoeff = dCoeff;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setImage(Icon image) {
		this.image = image;
	}

	public Icon getImage() {
		return image;
	}

	public void event() {
		CurrentTransaction t = (CurrentTransaction) Controller
				.getCurrentTransaction();
		t.setUser(this);
		t.setFree();
		Controller.gui.update();
		Controller.getGUI().showItems();
		//FIXME this is awful. User should now nothing about this.\
		//maybe better to call Controller.submitTransaction ?
		//Controller.getGUI().transactionControls.submitTransaction();
		}

	public float getDiscountCoeff() {
		return discCoeff;
	}

	public String toString() {
		return name;
	}
}
